package com.flower.hooc.service.impl;

import com.flower.hooc.bean.pojo.entity.Cart;
import com.flower.hooc.mapper.CartMapper;
import com.flower.hooc.service.CartService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class CartServiceImpl implements CartService {
    private Logger logger = LoggerFactory.getLogger(CartServiceImpl.class);

    @Autowired
    private CartMapper cartMapper;

    @Override
    public List<Cart> findCartByUserId(long userID) {
        List<Cart> cars = cartMapper.selectCarByUserId(userID);
        return cars;
    }

    @Override
    public int deleteCartByUid(long userId) {
        int result = cartMapper.deleteCartByUid(userId);
        return result;
    }

    @Override
    public int addCart(long userId, long courseId, BigDecimal price) {
        int result = cartMapper.addCart(userId, courseId, price);
        return result;
    }

}
